Add bushnell_trl.
authorrobertl <robertl>
Wed, 16 Dec 2009 04:45:25 +0000 (04:45 +0000)
committerrobertl <robertl>
Wed, 16 Dec 2009 04:45:25 +0000 (04:45 +0000)
Makefile.in
bushnell_trl.c [new file with mode: 0644]
vecs.c

index 36d3dae7e484d73d10f204d7c83af50b71ab5d27..d1a3521e3756bce154a59fee68fa70070fe1ed90 100644 (file)
@@ -64,7 +64,7 @@ ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o pcx.o cetus.o copilot.o \
        igo8.o gopal.o humminbird.o mapasia.o gnav_trl.o navitel.o ggv_ovl.o \
        jtr.o sbp.o sbn.o mmo.o skyforce.o itracku.o v900.o delbin.o \
        pocketfms_bc.o pocketfms_fp.o pocketfms_wp.o naviguide.o enigma.o \
-       vpl.o teletype.o jogmap.o bushnell.o \
+       vpl.o teletype.o jogmap.o bushnell.o bushnell_trl.o \
 
 FMTS=@FMTS@
 
diff --git a/bushnell_trl.c b/bushnell_trl.c
new file mode 100644 (file)
index 0000000..7b6dd85
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+    Read and write Bushnell trail *.trl files.
+
+    Copyright (C) 2009  Robert Lipe (robertlipe@gpsbabel.org)
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+
+#include "defs.h"
+#define MYNAME "Bushnell Trail"
+
+static gbfile *file_in;
+static route_head* trk_head;
+
+static
+arglist_t bushnell_args[] = {
+  ARG_TERMINATOR
+};
+
+static void
+rd_init(const char *fname) {
+  char h[0x14]; // Believed to be zero terminated.
+  file_in = gbfopen_le(fname, "rb", MYNAME);
+  gbfread(h, 1, sizeof(h), file_in);
+
+  trk_head = route_head_alloc();
+  track_add_head(trk_head);
+
+  trk_head->rte_name = xstrdup(lrtrim(h));
+}
+
+static void
+rd_deinit(void) {
+  gbfclose(file_in);
+}
+
+/*
+ * Each file contains a single waypoint.
+ */
+static void
+bushnell_read(void) {
+  int lat_tmp,lon_tmp;
+
+  while (1) {
+    waypoint *wpt_tmp;
+
+    lat_tmp = gbfgetint32(file_in);
+    lon_tmp = gbfgetint32(file_in);
+
+    if (!lat_tmp && !lon_tmp)
+      break;
+
+    wpt_tmp = waypt_new();
+    wpt_tmp->latitude  = lat_tmp / 10000000.0;
+    wpt_tmp->longitude = lon_tmp / 10000000.0;
+
+    track_add_wpt(trk_head, wpt_tmp);
+  }
+}
+
+
+ff_vecs_t bushnell_trl_vecs = {
+  ff_type_file,
+  { ff_cap_none, ff_cap_read, ff_cap_none },
+  rd_init,
+  NULL,
+  rd_deinit,
+  NULL,
+  bushnell_read,
+  NULL,
+  NULL,
+  bushnell_args,
+  CET_CHARSET_MS_ANSI, 0  /* Not really sure... */
+};
diff --git a/vecs.c b/vecs.c
index c260ca5c4c69e9a9c630f2054cca87d5c62198e6..2be6dce4d1fe39413dbe4ddc8c100c0414f1ef52 100644 (file)
--- a/vecs.c
+++ b/vecs.c
@@ -160,6 +160,7 @@ extern ff_vecs_t ng_vecs;
 extern ff_vecs_t sbn_vecs;
 extern ff_vecs_t mmo_vecs;
 extern ff_vecs_t bushnell_vecs;
+extern ff_vecs_t bushnell_trl_vecs;
 extern ff_vecs_t skyforce_vecs;
 extern ff_vecs_t v900_vecs;
 extern ff_vecs_t pocketfms_bc_vecs;
@@ -913,13 +914,19 @@ vecs_t vec_list[] = {
                 "Memory-Map Navigator overlay files (.mmo)",
                 "mmo"
         },
-#if PLANE
+#if PLANE || 1
         {
                 &bushnell_vecs,
                 "bushnell",
-                "Bushnell GPS file",
+                "Bushnell GPS Waypoint file",
                 "wpt"
         },
+        {
+                &bushnell_trl_vecs,
+                "bushnell_trl",
+                "Bushnell GPS Trail file",
+                "trl"
+        },
 #endif
         {
                &skyforce_vecs,